// ITI 1120 Winter 2012, Lab 4, Exercise 2 // Name: Gilbert Arbez, Student# 123456 /** * Requests from the user an integer value, stored in n * Calls the method to print 1 to N. */ class Lab4Ex2Sol { /** */ public static void main (String args[ ]) { // DECLARE VARIABLES/DATA DICTIONARY int n; // maximum number to pring // PRINT OUT IDENTIFICATION INFORMATION System.out.println("ITI 1120 Winter 2012, Lab 4, Exercise 2"); System.out.println("Name: Grace Hoper, Student# 12345678"); System.out.println(); // READ IN GIVENS use our ITI1120 special class for keyboard input System.out.print("Please give an integer value for N: "); n = ITI1120.readInt(); // BODY OF ALGORITHM - Call to the method to solve problem print1toN(n); // PRINT OUT RESULTS AND MODIFIEDS } // Problem Solving Method // METHOD Name: Prints the integer values from 1 to n // Parameters (GIVENS): n - maximum number to print public static void print1toN(int n) { // DECLARE VARIABLES/DATA DICTIONARY // no results // Intermediates int count; // counter from 1 to n // no results // BODY OF ALGORITHM count = 1; while(count <= n) { System.out.println(count); count = count+1; } // RETURN RESULT return ; } } // Don't remove this brace bracket!